package commands
{
	public class CommandStack
	{
		private static var _instance:CommandStack;
		private var _commands:Array;
		private var _index:uint;
		
		public function CommandStack()
		{
			_commands = new Array;
			_index = 0;
		}
		
		public static function getInstance():CommandStack{
			if(_instance == null){
				_instance = new CommandStack();
			}
			return _instance;
		}
		
		public function putCommand(command:ICommand):void{
			_commands[_index++] = command;
			_commands.splice(_index,_commands.length-_index);
		}
		public function previous():ICommand{
			return _commands[--_index];
		}
		public function next():ICommand{
			return _commands[_index++];
		}
		public function hasPreviousCommands():Boolean{
			return _index > 0;
		}
		public function hasNextCommands():Boolean{
			return _index < _commands.length;
		}
		
	}
}